package 力扣日常刷题.木23一月.第08天308;

import 力扣日常刷题.ListNode;

/**
 * @author 帅小伙
 * @date 2022/3/8
 * @description
 */
public class Demo19合并两个有序链表 {


    public ListNode mergeTwoLists(ListNode l1,ListNode l2) {
        if(l1 == null) return l2;
        else if(l2 == null) return l1;
        else if(l1.val > l2.val) {
            l2.next = mergeTwoLists(l1,l2.next);
            return l2;
        }else{
            l1.next = mergeTwoLists(l1.next,l2);
            return l1;
        }
    }
}
